package com.railway.switchs.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName EnumInfoType枚举类
 * @Author 魏梓晟
 * @Version 1.0
 **/
public enum EnumOperatorBillType {

    USER_INFO("0","用户"),
    AUTHORITY_ROLE("1","角色"),
    AUTHORITY_PERMISSION("2","权限"),
    BASE_INFO("3","基础信息"),
    BASE_DEVICE("4","基础设备"),
    DEVICE_INFO("5","设备信息"),
    REPAIR_TASK("6","检修任务"),
    REPAIR_RECORD("7","检修记录"),
    ROAD_SWITCH("8","铁路段道岔信息"),
    SWITCH_INFO("9","道岔信息"),
    SYS_NEWS("A","新闻");

    private String code;

    private String name;

    private EnumOperatorBillType(String code, String name){
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    private static Map<String, EnumOperatorBillType> pool = new HashMap<>();

    static {
        for (EnumOperatorBillType each : EnumOperatorBillType.values()) {
            pool.put(each.getCode(), each);
        }
    }

    public static EnumOperatorBillType get(String code) {
        return pool.get(code);
    }

    public static Map<String, String> getAllEnums() {
        Map<String, String> m = new HashMap<String, String>();
        for (EnumOperatorBillType e : EnumOperatorBillType.values()) {
            m.put(e.getCode(), e.getName());
        }
        return m;
    }

    public static String getName(String code){
        EnumOperatorBillType enums = pool.get(code);
        if (enums == null) {
            return "";
        }
        return enums.getName();
    }
}
